package com.roc.web.action.unPay;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class UnPayStatementSearchCondition extends BaseSearchCondition {

	private static final long serialVersionUID = 1L;
	
	private String merchantNo;//商户号
	private String terminalNo;//终端号
	private String accountNo;//交易卡号
	private String branch;//机构号
	private String transDate;//交易日期
	private String startDate;//交易起始日期
	private String endDate;//交易结束日期
	private String isHandle;//是否清算
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		if(Constance.isNotEmpty(merchantNo)){
			filedBeanList.add(new WhereHQLFieldBean("u.merchantNo", merchantNo.trim(),"=", false));
		}
		if(Constance.isNotEmpty(terminalNo)){
			filedBeanList.add(new WhereHQLFieldBean("u.terminalNo", terminalNo.trim(),"=", false));
		}
		if(Constance.isNotEmpty(accountNo)){
			filedBeanList.add(new WhereHQLFieldBean("u.account", accountNo.trim(),"=", false));
		}
		if(Constance.isNotEmpty(branch)){
			filedBeanList.add(new WhereHQLFieldBean("u.branch", branch.trim(),"=", false));
		}
		if (Constance.isNotEmpty(startDate) && Constance.isNotEmpty(endDate)) {
			
			filedBeanList.add(new WhereHQLFieldBean("u.transDate", startDate.trim(), ">=", false));
			filedBeanList.add(new WhereHQLFieldBean("u.transDate", endDate.trim(), "<=", false));
		}
		if("Y".equals(isHandle)){
			filedBeanList.add(new WhereHQLFieldBean("u.ishandle", "Y","=", false));
		}else if("N".equals(isHandle)||"".equals(Constance.isNotEmpty(isHandle))){
			filedBeanList.add(new WhereHQLFieldBean("(u.ishandle is null or u.ishandle='N')"));
		}
		 
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" select count(1) from yj_upay_trans u where u.transresult='00' ");
		return sb.toString();
	}

	@Override
	protected String getSearchHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" select u.merchantno,u.terminalno,u.serialno,u.branch,u.sysno,u.account,u.amt,u.transresult,");
		sb.append("u.cardtype,u.transamt,u.fee,u.settleamt,u.transdate,u.settledate,u.ishandle from  yj_upay_trans  u where u.transresult='00' ");
		return sb.toString();
	}

	@Override
	protected String getOrderPartOfHQL() {
		
		return " order by u.transdate desc ";
	}

	public String getMerchantNo() {
		return merchantNo;
	}

	public void setMerchantNo(String merchantNo) {
		this.merchantNo = merchantNo;
	}

	public String getTerminalNo() {
		return terminalNo;
	}

	public void setTerminalNo(String terminalNo) {
		this.terminalNo = terminalNo;
	}

	public String getAccountNo() {
		return accountNo;
	}

	public void setAccountNo(String accountNo) {
		this.accountNo = accountNo;
	}

	public String getBranch() {
		return branch;
	}

	public void setBranch(String branch) {
		this.branch = branch;
	}

	public String getTransDate() {
		return transDate;
	}

	public void setTransDate(String transDate) {
		this.transDate = transDate;
	}

	public String getStartDate() {
		return startDate;
	}

	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	public String getIsHandle() {
		return isHandle;
	}

	public void setIsHandle(String isHandle) {
		this.isHandle = isHandle;
	}

}
